import { createStore, combineReducers, applyMiddleware } from 'redux';
import logger from 'redux-logger'
import homeReducer from './home/homeReducer'
import carReducer from './car/carReducer'
const rootReducer = combineReducers({
	home: homeReducer,
	car: carReducer
})

const store = createStore(rootReducer, applyMiddleware(logger));
// 获取仓库数据类型
export type RootState = ReturnType<typeof store.getState>

store.subscribe(() => {
	const state = store.getState();
	localStorage.setItem('car', JSON.stringify(state.car.car))
})

export default store